package com.example.provider.qiniuyun;

import java.io.File;
import java.io.IOException;

/**
 * All rights Reserved, Designed By www.maihaoche.com
 *
 * @Package com.example.provider.qiniuyun
 * @author: 红雪（hongxue@maihaoche.com）
 * @date: 2019/1/28 5:42 PM
 * @Copyright: 2017-2020 www.maihaoche.com Inc. All rights reserved.
 * 注意：本内容仅限于卖好车内部传阅，禁止外泄以及用于其他的商业项目
 */
public class Test {
    public static void main(String[] args) throws IOException {
        IFileService iFileService = FileServiceFactory.getInstance(UploadToolsBuilder.dBuilder().uploadInstanceEnum(UploadInstanceEnum.QINIU).qiniuBase(new DefaultPrivateQiniu()).build());
        //测试获得签名url
        //System.out.println(iFileService.sign("plvou2uto.bkt.clouddn.com/hongxue.jpg").getData());

        File file = new File("/Users/durui/Pictures/test.jpg");
        //测试upload(File file)
        //iFileService.upload(file);

        //测试upload(File file,String fileName) 测试覆盖上传
        //iFileService.upload(file,"test.jpg");

        //测试 upload(byte[] fileBytes,String fileName)
       /* FileInputStream inputStream = new FileInputStream(file);
        byte[] bytes = new byte[(int)file.length()];
        inputStream.read(bytes);
        iFileService.upload(bytes,"test1.jpg");*/

       //测试uploadResume(File file)
       File fileBig = new File("/Users/durui/Pictures/fileBig.rar");
        //iFileService.uploadResume(fileBig);

        //测试uploadResume(File file,String fileName)
       // iFileService.uploadResume(fileBig,"test.jar");

        //测试 uploadByFecth(String url)
        //iFileService.uploadByFecth("http://plvou2uto.bkt.clouddn.com/hongxue.jpg");

        //测试 uploadByFecth(String url,String fileName)
        //iFileService.uploadByFecth("http://plvou2uto.bkt.clouddn.com/hongxue.jpg","upload.jpg");

        //测试 getUploadToken()
        System.out.println(iFileService.getUploadToken().getData());

        //测试 sign(String url)
        System.out.println(iFileService.sign("plvou2uto.bkt.clouddn.com/upload.jpg").getData());

        //sign(String url,Long expireInSeconds)
        System.out.println(iFileService.sign("plvou2uto.bkt.clouddn.com/upload.jpg",3600L).getData());



    }
}
